<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>XXX统一登录平台</title>
    <script
            src="https://code.jquery.com/jquery-3.4.1.min.js"
            integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
            crossorigin="anonymous"></script>
</head>
<body>

<form action="">

    <input id="url_input" type="hidden" th:value="${url}" />

    用户名： <input type="text" name="username" value="zhangsan" /> <br/>
    密码： <input type="password" name="password" value="123456" /> <br/>
    <input type="submit"> <a href="javascript:location.href='/register';">注册</a>
</form>

<script>

    var url = $("#url_input").val();

    function login() {
        var data = $("form").serialize();

            $.getJSON("/login", data, function(ret) {
            if(ret.status == 200) {
                location.href = url;
            } else {
                alert(ret.msg);
            }
        })
    }

    $("form").submit(function() {
        login();
        return false;
    });

</script>

</body>
</html>